package com.ccsoft.atools.controller;

import com.ccsoft.atools.model.ContactCompany;
import com.ccsoft.atools.service.ContactCompanyService;
import com.ccsoft.atools.utils.BusinessException;
import com.ccsoft.atools.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/contactCompany")
public class ContactCompanyController {

    @Autowired
    private ContactCompanyService service;

    @DeleteMapping("/deleteByPrimaryKey/{iid}")
    public JsonResult deleteByPrimaryKey(@PathVariable Integer iid) {
        return JsonResult.ok(service.deleteByPrimaryKey(iid));
    }

    @PostMapping("/insert")
    public JsonResult insert(@RequestBody ContactCompany record) {
        return JsonResult.ok(service.insertSelective(record));
    }

    @GetMapping("/selectByPrimaryKey/{iid}")
    public JsonResult selectByPrimaryKey(@PathVariable Integer iid) {
        return JsonResult.ok(service.selectByPrimaryKey(iid));
    }

    @PutMapping("/update")
    public JsonResult updateByPrimaryKey(@RequestBody ContactCompany record) {
        return JsonResult.ok(service.updateByPrimaryKey(record));
    }

    @GetMapping("/selectAll")
    public JsonResult selectAll() {
        return JsonResult.ok(service.selectAll());
    }

    @GetMapping("/isExist/{sid}")
    public JsonResult isExist(@PathVariable String sid) {
        return JsonResult.ok(service.isExist(sid));
    }

    @GetMapping("/selectByType/{typeSid}")
    public JsonResult selectByType(@PathVariable String typeSid) {
        return JsonResult.ok(service.selectByType(typeSid));
    }
}
